home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2058 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1011 b 

  1. Path: netnews1.apci.com!usenet
  2. From: wardmw@apci.com (Martin Ward)
  3. Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.perl
  4. Subject: Re: Stupid array problems
  5. Date: Mon, 15 Jan 1996 08:08:37 GMT
  6. Organization: Air Products Europe
  7. Message-ID: <4dd2ad$3hp@netnews1.apci.com>
  8. References: <4d9b9v$14n@paperboy.ids.net>
  9. Reply-To: wardmw@apci.com
  10. NNTP-Posting-Host: p1862.apci.com
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. Hi Seth,
  14.  
  15. Two answers spring to mind.
  16.  
  17. 1) If your array is large and fixed in size, you could set the array element to
  18. NULL when you free() it. Then when you loop through the array looking at
  19. elements you simply test for (elem == NULL) first.
  20.  
  21. 2) If your array is small and fixed in sized, you could simply shuffle all the
  22. elements after the freed one up to fill the space you've just emptied.
  23.  
  24. 3) (The most complicated one, but not too difficult) you could implement the
  25. whole array as a liked list. The when you delete an element, you simply repoint
  26. the prevous element to the next one.
  27.  
  28. HTH.
  29.  
  30. |\/|
  31.  
  32.